<include file="Public/header" />
<title>我的桌面</title>
</head>
<body>
<div class="page-container">
    <div class="text-c"> 日期范围：
        <input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})" id="logmin" name="start_time" value="<{$Think.get.start_time}>" class="input-text Wdate" style="width:120px;">
        -
        <input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})" id="logmax" name="end_time" value="<{$Think.get.end_time}>" class="input-text Wdate" style="width:120px;">
        <input type="text" name="name" id="name" value="<{$Think.get.name}>" placeholder=" 计划入库单号" style="width:250px" class="input-text">
        <button id="search" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜索</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="delAll()" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a>
            <a class="btn btn-primary radius" data-title="添加计划入库单" _href="article-add.html" onclick="add()" href="javascript:;"><i class="Hui-iconfont"></i> 添加计划入库单</a>
			
        </span>
        <span class="r">共有数据：<strong><{$count}></strong> 条</span>
    </div>
    <div class="mt-20">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
            <div style="margin-bottom: 12px;" class="Huialert Huialert-info"><i class="icon-remove"></i>已经推送的计划入库单信息将在“商品管理”中进行管理</div>
            <div class="dataTables_length" id="DataTables_Table_0_length">
                <label>显示 <select tabindex="<{$Think.get.page_count}>" name="page_count" aria-controls="DataTables_Table_0" class="select">
                <option value="15">15</option><option value="25">25</option><option value="50">50</option>
                <option value="100">100</option></select> 条</label>
            </div>
            <table class="table table-border table-bordered table-bg table-hover table-sort dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
            <thead>
            <tr class="text-c" role="row">
                <th width="25" class="sorting_disabled" rowspan="1" colspan="1" aria-label="" style="width: 25px;"><input type="checkbox" name="" value=""></th>
                <th width="80" class="sorting_desc" tabindex="id" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-sort="descending" style="width: 80px;">ID</th>
                <th width="80" class="sorting" tabindex="order_no">单据编号</th>
                <th width="80" class="sorting" tabindex="making">制单人</th>
                <th width="80" class="sorting" tabindex="purchaser">申请人</th>
                <th width="80" class="sorting" tabindex="department">部门</th>
                <th width="80" class="sorting" tabindex="from_company">来往单位</th>
                <th width="160">申请理由 </th>
				<th width="160">账册编号 </th>
                <th width="100">已审核数/总数</th>
                <th width="60" class="sorting" tabindex="operator" style="width: 70px;">操作人</th>
                <th width="100">推送状态</th>
                <th width="120" style="width: 120px;" class="sorting" tabindex="created_at">添加时间</th>
                <th width="140" class="sorting_disabled" rowspan="1" colspan="1" aria-label="操作" style="width: 120px;">操作</th></tr>
            </thead>
            <tbody>
            <foreach name="list" item="data">
            <tr class="text-c odd" role="row">
                <td><neq name="data.is_examined" value="4"><input type="checkbox" value="<{$data.id}>" name=""></neq></td>
                <td class="sorting_1"><{$data.id}></td>
                <td class="text-l"><{$data.order_no}></td>
                <td><{$data.making}></td>
                <td><{$data.purchaser}></td>
                <td><{$data.department}></td>
                <td><{$data.from_company}></td>
                <td><{$data.app_reasons}></td>
				<td><{$data.manua_id}></td>
                <td class="td-status"><span class="label label-success radius"><{$data.some_back}>/<{$data.all_back}></span></td>
                <td><{$data.operator}></td>
                <td><eq name="data.is_examined" value="4">已推送<else/>未推送</eq></td>
                <td><{$data.created_at}></td>
                <td class="f-14 td-manage">
                    <neq name="data.is_examined" value="4">
                    <a style="text-decoration:none" class="ml-5 label label-success radius" onclick="examined('<{$data.id}>','<{$data.is_examined}>')" href="javascript:;" title="审批">
                        <if condition="$data.is_examined eq 0">
                            一级审批
                            <elseif condition="$data.is_examined eq 1"/>
                            二级审批
                            <elseif condition="$data.is_examined eq 2"/>
                            三级审批
                            <else/>
                            推送
                        </if>
                    </a>
                    </neq>
                    <a style="text-decoration:none" class="ml-5 label label-success radius" onclick="detail('<{$data.id}>')" href="javascript:;" title="详情">详情</a>
					<a style="text-decoration:none" class="ml-5 label label-success radius" onclick="print('<{$data.id}>')" href="javascript:;" title="打印">打印</a>
                    <neq name="data.is_examined" value="4">
                        <a style="text-decoration:none" class="ml-5" onclick="edit('<{$data.id}>')" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a>
                        <a style="text-decoration:none" class="ml-5" onclick="del('<{$data.id}>')" href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a>
                    </neq>
                </td>
            </tr>
            </foreach>
            </tbody>
        </table>
            <div class="page">
                <{$page}>
            </div>
    </div>
</div>
</div>
<include file="Public/footer" />
<include file="Public/footer_js" />
<script>
    function add(){
        $.get('__CONTROLLER__/warehouse_select_session_delete');
        location.href="__MODULE__/InboundPlan/add";
    }
    function edit(id){
        var index=layer.open({
            type: 2,
            title: '计划入库单修改',
            shadeClose: true,
            shade: 0.5,
            area: ['400px', '488px'],
            content: '__MODULE__/InboundPlan/edit/id/'+id+"/"+Math.random() //iframe的url
        });
    }
    function detail(id){
        $.get('__CONTROLLER__/warehouse_select_session_delete');
        location.href= '__MODULE__/InboundPlan/detail/id/'+id+"/"+Math.random();
    }
	function print(id){
		var index=layer.open({
            type: 2,
            title: '打印计划入库单',
            shadeClose: true,
            shade: 0.5,
            area: ['1100px', '600px'],
            content: '__MODULE__/InboundPlan/print_examinedetail/id/'+id+"/"+Math.random() //iframe的url
        });
    }
    function delAll(){
        var all_ipt=$("#DataTables_Table_0_wrapper input[type=checkbox]:checked");
        var group_id='';
        for(var i=0;i<all_ipt.length;i++){
            if(all_ipt.eq(i).val()!==''){
                group_id+='@'+all_ipt.eq(i).val();
            }
        }
        if(group_id.substring(1)==''){
            layer.msg('请勾选要删除的信息');
            return false;
        }
        del(group_id.substring(1));
    }
    function del(id){
        $.get('__MODULE__/InboundPlan/del',{
            id:id,
        },function (msg){
            layer.msg(msg.data);
            if(msg.flag==1){
                setTimeout(function (){
                    location.reload();
                },800);
            }
        },'json');
    }
    function push(id){
        if(id==''){
            layer.msg('操作有误');
            return false;
        }
        $.get('__MODULE__/InboundPlan/push',{
            id:id,
        },function (msg){
            layer.msg(msg.data);
            if(msg.flag==1){
                setTimeout(function (){
                    location.reload();
                },800);
            }
        },'json');
    }
    function examined(id,level){
        if(level==3){
            push(id);
            return false;
        }
        level*=1;
        if(id==''){
            layer.msg('操作有误');
            return false;
        }
        if(level>2 || level<0){
            layer.msg('操作有误');
            return false;
        }
        $.get('__MODULE__/InboundPlan/examined_'+(level+1),{
            id:id,
        },function (msg){
            layer.msg(msg.data);
            if(msg.flag==1){
                setTimeout(function (){
                    location.reload();
                },800);
            }
        },'json');
    }
    $("select[name=page_count]").on('change',function (){
        search();
    });
    $("#search").on('click',function (){
        search();
    });
    function search(_this){
        var page_count=$("select[name=page_count]").val();
        var start_time=$("input[name=start_time]").val();
        var end_time=$("input[name=end_time]").val();
        var name=$("input[name=name]").val();
        var category=$("select[name=category]").val();
        var sort,dec;
        if(_this){
            if(_this.attr('class')=='sorting_desc'){
                sort=_this.attr('tabindex');
                dec='asc';
            }
            if(_this.attr('class')=='sorting_asc'){
                sort=_this.attr('tabindex');
                dec='desc';
            }
            if(_this.attr('class')=='sorting'){
                sort=_this.attr('tabindex');
                dec='asc';
            }
        }else{
            sort='';
            dec='';
        }
        location.href="__ACTION__?name="+name+"&category="+category+"&page_count="+page_count+"&start_time="+start_time+"&end_time="+end_time+"&sort="+sort+"&dec="+dec;
    }

    (function(){
        if($("select[name=page_count]").attr('tabindex')==''){
            var  page=15;
        }else{
            var  page=$("select[name=page_count]").attr('tabindex');
        }
        $("select[name=page_count]").prop('value',page);
        $(".sorting,.sorting_desc,.sorting_asc").click(function (){
            search($(this));
        });
        for(var i=0;i<$(".sorting,.sorting_desc,.sorting_asc").length;i++){
            if('<{$Think.get.sort}>'!=''){
                if($(".sorting,.sorting_desc,.sorting_asc").eq(i).attr('tabindex')=='<{$Think.get.sort}>'){
                    $(".sorting,.sorting_desc,.sorting_asc").attr('class','sorting');
                    $(".sorting,.sorting_desc,.sorting_asc").eq(i).attr('class','sorting_<{$Think.get.dec}>');
                }
            }
        }
    })();
</script>
</body>
</html>